package org.framework.lazy.cloud.network.heartbeat.server.standalone.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.LazyProxyFlowApplication;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.command.lazy.proxy.flow.*;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.dto.LazyClientProxyFlowDTO;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.dto.LazyProxyFlowDTO;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.dto.LazyVisitorFlowDTO;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.domain.model.lazy.proxy.flow.LazyProxyFlow;
import org.springframework.web.bind.annotation.*;
import org.wu.framework.lazy.orm.database.lambda.domain.LazyPage;
import org.wu.framework.web.response.Result;
import org.wu.framework.web.spring.EasyController;

import java.util.List;

/**
 * describe 代理流量
 *
 * @author Jia wei Wu
 * @date 2025/06/06 11:39 晚上
 * @see org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyController
 **/
@Tag(name = "代理流量提供者")
@EasyController("/lazy/proxy/flow")
public class LazyProxyFlowProvider {

    @Resource
    private LazyProxyFlowApplication lazyProxyFlowApplication;

    /**
     * describe 新增代理流量
     *
     * @param lazyProxyFlowStoryCommand 新增代理流量
     * @return {@link Result<LazyProxyFlow>} 代理流量新增后领域对象
     * @author Jia wei Wu
     * @date 2025/06/06 11:39 晚上
     **/

    @Operation(summary = "新增代理流量")
    @PostMapping("/story")
    public Result<LazyProxyFlow> story(@RequestBody LazyProxyFlowStoryCommand lazyProxyFlowStoryCommand) {
        return lazyProxyFlowApplication.story(lazyProxyFlowStoryCommand);
    }

    /**
     * describe 批量新增代理流量
     *
     * @param lazyProxyFlowStoryCommandList 批量新增代理流量
     * @return {@link Result<List<LazyProxyFlow>>} 代理流量新增后领域对象集合
     * @author Jia wei Wu
     * @date 2025/06/06 11:39 晚上
     **/

    @Operation(summary = "批量新增代理流量")
    @PostMapping("/batchStory")
    public Result<List<LazyProxyFlow>> batchStory(@RequestBody List<LazyProxyFlowStoryCommand> lazyProxyFlowStoryCommandList) {
        return lazyProxyFlowApplication.batchStory(lazyProxyFlowStoryCommandList);
    }

    /**
     * describe 更新代理流量
     *
     * @param lazyProxyFlowUpdateCommand 更新代理流量
     * @return {@link Result<LazyProxyFlow>} 代理流量领域对象
     * @author Jia wei Wu
     * @date 2025/06/06 11:39 晚上
     **/

    @Operation(summary = "更新代理流量")
    @PutMapping("/updateOne")
    public Result<LazyProxyFlow> updateOne(@RequestBody LazyProxyFlowUpdateCommand lazyProxyFlowUpdateCommand) {
        return lazyProxyFlowApplication.updateOne(lazyProxyFlowUpdateCommand);
    }

    /**
     * describe 查询单个代理流量
     *
     * @param lazyProxyFlowQueryOneCommand 查询单个代理流量
     * @return {@link Result<LazyProxyFlowDTO>} 代理流量DTO对象
     * @author Jia wei Wu
     * @date 2025/06/06 11:39 晚上
     **/

    @Operation(summary = "查询单个代理流量")
    @GetMapping("/findOne")
    public Result<LazyProxyFlowDTO> findOne(@ModelAttribute LazyProxyFlowQueryOneCommand lazyProxyFlowQueryOneCommand) {
        return lazyProxyFlowApplication.findOne(lazyProxyFlowQueryOneCommand);
    }

    /**
     * describe 查询多个代理流量
     *
     * @param lazyProxyFlowQueryListCommand 查询多个代理流量
     * @return {@link Result<List<LazyProxyFlowDTO>>} 代理流量DTO对象
     * @author Jia wei Wu
     * @date 2025/06/06 11:39 晚上
     **/

    @Operation(summary = "查询多个代理流量")
    @GetMapping("/findList")
    public Result<List<LazyProxyFlowDTO>> findList(@ModelAttribute LazyProxyFlowQueryListCommand lazyProxyFlowQueryListCommand) {
        return lazyProxyFlowApplication.findList(lazyProxyFlowQueryListCommand);
    }

    /**
     * describe 分页查询多个代理流量
     *
     * @param lazyProxyFlowQueryListCommand 分页查询多个代理流量
     * @return {@link Result<LazyPage<LazyProxyFlowDTO>>} 分页代理流量DTO对象
     * @author Jia wei Wu
     * @date 2025/06/06 11:39 晚上
     **/

    @Operation(summary = "分页查询多个代理流量")
    @GetMapping("/findPage")
    public Result<LazyPage<LazyProxyFlowDTO>> findPage(@Parameter(description = "分页大小") @RequestParam(defaultValue = "10", value = "size") int size,
                                                       @Parameter(description = "当前页数") @RequestParam(defaultValue = "1", value = "current") int current, @ModelAttribute LazyProxyFlowQueryListCommand lazyProxyFlowQueryListCommand) {
        return lazyProxyFlowApplication.findPage(size, current, lazyProxyFlowQueryListCommand);
    }

    /**
     * 根据客户端查询流量
     *
     * @param size                          分页大小
     * @param current                       分页
     * @param lazyProxyFlowQueryListCommand 查询条件
     * @return {@link Result<LazyPage<   LazyVisitorFlowDTO   >>} 分页访客端流量DTO对象
     */
    @Operation(summary = "分页查询多个访客端流量")
    @GetMapping("/findClientFlowPage")
    public Result<LazyPage<LazyClientProxyFlowDTO>> findClientFlowPage(@Parameter(description = "分页大小") @RequestParam(defaultValue = "10", value = "size") int size,
                                                                       @Parameter(description = "当前页数") @RequestParam(defaultValue = "1", value = "current") int current,
                                                                       @ModelAttribute LazyProxyFlowQueryListCommand lazyProxyFlowQueryListCommand) {
        return lazyProxyFlowApplication.findClientFlowPage(size, current, lazyProxyFlowQueryListCommand);
    }

    /**
     * describe 删除代理流量
     *
     * @param lazyProxyFlowRemoveCommand 删除代理流量
     * @return {@link Result<LazyProxyFlow>} 代理流量
     * @author Jia wei Wu
     * @date 2025/06/06 11:39 晚上
     **/

    @Operation(summary = "删除代理流量")
    @DeleteMapping("/remove")
    public Result<LazyProxyFlow> remove(@ModelAttribute LazyProxyFlowRemoveCommand lazyProxyFlowRemoveCommand) {
        return lazyProxyFlowApplication.remove(lazyProxyFlowRemoveCommand);
    }
}